<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/index.css" />
	</head>
	<body>
		<h1>中博年会抽奖环节</h1>
		<div class="start">开始抽奖</div>
		<ul>
			<li>徐小琴</li>
			<li>雷璇</li>
			<li>郝天翔</li>
			<li>肖雨涵</li>
			<li>张辉</li>
		</ul>
		<video id="bgMov" loop="loop" autoplay="autoplay" muted="" src="img/bg.mp4"></video>
		<img src="img/bg.jpg" src="img/bg.jpg" class="main">
	</body>
	<script src="./js/data.js"></script>
	<script type="text/javascript">
		
		var start = document.querySelector(".start");
		var p1 = document.querySelector("li:nth-of-type(1)");
		var p2 = document.querySelector("li:nth-of-type(2)");
		var p3 = document.querySelector("li:nth-of-type(3)");
		var p4 = document.querySelector("li:nth-of-type(4)");
		var p5 = document.querySelector("li:nth-of-type(5)"); 
		var timer = null;

		start.onclick = function change() {
			if (start.innerText == "开始抽奖") {
				start.innerText = "停止";
				timer = setInterval(function() { 
					p1.innerText = list[Math.floor(Math.random() * list.length)]; 
					p2.innerText = list[Math.floor(Math.random() * list.length)]; 
					p3.innerText = list[Math.floor(Math.random() * list.length)]; 
					p4.innerText = list[Math.floor(Math.random() * list.length)]; 
					p5.innerText = list[Math.floor(Math.random() * list.length)]; 
				}, 200);

			} else {
				start.innerText = "开始抽奖";
				clearInterval(timer);
			}

		}
	</script>
</html>
